package work20241126_27;

import java.util.Arrays;

/**
 * @author zdl
 * @date 2024/11/26
 */
public class Demo26 {
    public static void main(String[] args) {
        //将两个已排序的数组合并为一个排序后的数组。
        int[] arr1 = {4,5,6};
        int[] arr2 = {1,2,3};
        int[] new_arr = new int[arr1.length+ arr2.length];
        int index= 0;
        for (int i = 0; i < arr1.length; i++) {
            new_arr[index++] = arr1[i];
        }
        for (int i = 0; i < arr2.length; i++) {
            new_arr[index++] = arr2[i];
        }
        System.out.println(Arrays.toString(new_arr));
        for (int i = 0; i < new_arr.length; i++) {
            for (int j = 0; j < new_arr.length - 1; j++) {
                if (new_arr[j] > new_arr[j+1]){
                    int temp = new_arr[j];
                    new_arr[j] = new_arr[j+1];
                    new_arr[j+1] = temp;
                }
            }
        }
        System.out.println("排序后的数组："+Arrays.toString(new_arr));
    }
}
